package com.maxlen.search.controller;

import com.maxlen.common.utils.R;
import com.maxlen.search.dto.SearchHomeDTO;
import com.maxlen.search.dto.SearchResultDTO;
import com.maxlen.search.service.MallSearchService;
import com.maxlen.search.vo.SearchParamVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/search/query")
public class SearchController {

    @Autowired
    private MallSearchService mallSearchService;

    /**
     * 查询商品详情
     * @param searchParamVO
     * @return
     */
    @GetMapping("/searchProduct")
    public R search(SearchParamVO searchParamVO){
        SearchResultDTO search = mallSearchService.getSearch(searchParamVO);
        return R.ok().put("data", search);
    }

    /**
     * 商品首页查询
     * @return
     */
    @GetMapping("/searchHome")
    public R searchHome(){
        List<SearchHomeDTO> searchHomeDTOList = mallSearchService.getSearchHome();
        return R.ok().put("data", searchHomeDTOList);
    }

}
